/* jtk.h */

#ifndef __JTK__
#define __JTK__

#include <cairo.h>

typedef unsigned long jtk_char;

enum jtk_callback_type {
    JTK_DRAW, 
    JTK_MOUSE_DOWN, 
    JTK_MOUSE_UP, 
    JTK_MOUSE_DRAG, 
    JTK_KEY_DOWN,
    JTK_TOTAL_CALLBACKS
};

enum jtk_event_type {
    JTK_EVENT_MOUSE_DOWN, 
    JTK_EVENT_MOUSE_UP, 
    JTK_EVENT_MOUSE_DRAG, 
    JTK_EVENT_KEY_DOWN, 
};

typedef struct jtk_point {
    double x;
    double y;
} jtk_point;

typedef struct jtk_event {
    enum jtk_event_type type;

    /* the event occurred time in seconds 
     * since system startup */
    double timestamp;

    union {
        jtk_point point;
        jtk_char  key;
    } u;
} jtk_event;

#define JTK_NULL_CALLBACK   NULL

typedef void (*jtk_callback)(void *user);

extern jtk_callback jtk_callback_list[JTK_TOTAL_CALLBACKS];

void jtk_init(const char *title, int width, int height);
void jtk_main_loop();
void jtk_set_callback(int index, jtk_callback func);
void jtk_redraw();
void jtk_quit();

#endif

